package com.helper.dream.a361phonehelper.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.helper.dream.a361phonehelper.R;
import com.helper.dream.a361phonehelper.bean.SuperViseBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/12/23.
 */

public class ManagerHeaderAdapter extends RecyclerView.Adapter<ManagerHeaderAdapter.MyViewHolder> {
    LayoutInflater layoutInflater;
    Context context;
    List<SuperViseBean.FixBean> list;

    public ManagerHeaderAdapter(Context context, List<SuperViseBean.FixBean> list) {
        this.context = context;
        this.list = list;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.supervise_item_header_layout, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        SuperViseBean.FixBean fixBean = list.get(position);
        Picasso.with(context).load(fixBean.getLogo())
                .into(holder.iv);
        holder.tv.setText(fixBean.getTitle());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        ImageView iv;
        TextView tv;
        public MyViewHolder(View itemView) {
            super(itemView);
            iv = (ImageView) itemView.findViewById(R.id.supervise_iv);
            tv = (TextView) itemView.findViewById(R.id.supervise_tv);
        }
    }
}
